import { Scene } from "../../../../../Core/Module/Entity/Scene";
import { SceneType } from "../../../../../Core/Module/Entity/SceneType";
import { ActorMessageHandlerAttribute } from "../../../../../Decorator/Decorator";
import { ObjectGetRequest, ObjectGetResponse } from "../../../../Model/Generate/Share/Message/InnerMessage_S_20001";
import { LocationComponent } from "../../../../Model/Server/Module/ActorLocation/LocationComponent";
import { AMActorRpcHandler } from "../Actor/AMActorRpcHandler";

@ActorMessageHandlerAttribute(SceneType.Location, ObjectGetRequest, ObjectGetResponse)
export class ObjectGetRequestHandler extends AMActorRpcHandler<Scene, ObjectGetRequest, ObjectGetResponse>    {

    protected override async Run(scene: Scene, request: ObjectGetRequest, response: ObjectGetResponse): Promise<void> {
        const instanceId = await scene.GetComponent<LocationComponent>(LocationComponent).Get(request.Key);
        response.InstanceId = instanceId;
    }

}